package com.mediastory.spsserver.adCategory.dao.impl;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.session.RowBounds;
import org.mybatis.spring.support.SqlSessionDaoSupport;
import org.springframework.stereotype.Repository;

import com.mediastory.spsserver.adCategory.dao.AdCategoryDao;
import com.mediastory.spsserver.adCategory.domain.AdCategory;
import com.mediastory.spsserver.content.domain.Content;

@Repository
public class AdCategoryDaoImpl extends SqlSessionDaoSupport  implements AdCategoryDao {

	public AdCategoryDaoImpl() {
		// TODO Auto-generated constructor stub
	}

	@Override
	public List<AdCategory> SelectList(Map<String, Object> condition)
			throws Exception {
		// TODO Auto-generated method stub
		List<AdCategory> result = getSqlSession().selectList("AdCategory.selectList", condition);
		return result;
	}

	@Override
	public AdCategory select(Integer id) throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public AdCategory insert(AdCategory AdCategory) throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public AdCategory update(AdCategory AdCategory) throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public int delete(Integer id) throws Exception {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public List<Content> SelectListInCont(Map<String, Object> condition) throws Exception {
		// TODO Auto-generated method stub
		Integer page = (Integer)condition.get("page");
		Integer maxnum = (Integer)condition.get("maxnum");
		
		List<Content> result = null;
		if(page != null && maxnum != null){
			RowBounds rb = new RowBounds(page, maxnum);
			result = getSqlSession().selectList("AdCategory.selectList.inCont", condition, rb);
		}else{
			result = getSqlSession().selectList("AdCategory.selectList.inCont", condition);
		}

		return result;
	}
	
	@Override
	public Integer SelectListInContTotalCnt(Map<String, Object> condition)
			throws Exception {
		// TODO Auto-generated method stub
		Integer result = getSqlSession().selectOne("AdCategory.selectListTotalCnt.inCont", condition);
		return result;
	}

	@Override
	public List<Content> SelectListOutCont(Map<String, Object> condition)
			throws Exception {
		// TODO Auto-generated method stub
		List<Content> result = getSqlSession().selectList("AdCategory.selectList.outCont", condition);
		return result;
	}

	@Override
	public Integer insertDispOrder(Map<String, Object> condition)
			throws Exception {
		// TODO Auto-generated method stub
		int result = getSqlSession().insert("AdCategory.insert.dispOrder", condition);
		return result;
	}

	@Override
	public Integer deleteDispOrder(Map<String, Object> condition) throws Exception {
		// TODO Auto-generated method stub
		int result = getSqlSession().delete("AdCategory.delete.dispOrder", condition);
		return result;
	}

}